class Atm:
    
    
    def __init__(self):
        self.id = 0
        self.option = '0'
        self.user = {}
        self.user_info = [{'username':'user1','pwd':'111','money':11111},
        {'username':'user2','pwd':'222','money':22222},
        {'username':'user3','pwd':'333','money':33333},
        {'username':'user4','pwd':'444','money':44444}]
    def login_atm(self):
        login_user = input('登陆页面，请输入用户名：\n')
        user_isexists = 0
        id = 0
        while user_isexists == 0 :
            for user in self.user_info:
                if login_user.lower() == user['username']:
                    pwd = user['pwd']
                    login_pwd = input ('请输入密码:\n')
                    pwd_check = 0
                    while pwd_check == 0:
                        if pwd == login_pwd:
                            pwd_check = 1 
                            self.user = user               
                            self.id = id
                        else :
                            login_pwd = input ('密码错误，请重新输入密码:\n')
                    user_isexists = 1
                
                id += 1
            if user_isexists == 0:
                login_user = input('用户名不存在,请重新输入:\n')
            
    
    def query_balance(self):
        username = self.user['username']
        balance = self.user['money']
        print (username + ",您的余额是：" + str(balance))
    
    def change_money(self,money):
        username = self.user['username']
        balance = self.user['money']
        if self.option == '2':
            balance += money
            self.user['money'] = balance
            self.user_info[self.id] = self.user
        elif self.option == '3' and balance >= money:
            balance -= money
            self.user['money'] = balance
            self.user_info[self.id] = self.user
        elif self.option == '3' and balance < money :
            print ('余额为:' + str(balance) + '，不足'+ str(money) + "请重新选择金额提取\n")

        
    
atm = Atm()
login_state = True
user = atm.login_atm()

while login_state:
    option = input ("按1：查询余额，按2：存储现金，按3：提取现金，\n按q：退出登陆\n")
    atm.option = option
    if option == '1':
        atm.query_balance()        
    elif option =='2':
        money = input ("请确认存储现金： \n")
        atm.change_money(int(money))
        atm.query_balance()
    elif option =='3':
        money = input ("请输入提取现金： \n")
        atm.change_money(int(money))
        atm.query_balance()
    elif str(option)  == 'q':
        break
    print ('--------------------------')
print ('系统已退出!')
        
